﻿using System;
using System.Web.Services;

using Microsoft.Practices.EnterpriseLibrary.Logging;
using BizElements.BusinessLayer;

// Do NOT change this namespace. Otherwise client component (BizElements.BusinessLayer.FormattedWebServiceTraceListener) will not function properly.
namespace BizElements.Services
{
    /// <summary>Writes <b>LogEntry</b> objects in remote domain.</summary>
    [WebService(Namespace = "http://ElementsFx/BizElements.Services/WsLogReceiver/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    public class WsLogReceiver : System.Web.Services.WebService
    {
        /// <summary>Writes <b>LogEntry</b>.</summary>
        /// <param name="serializedLogEntry">Binary serialized <b>LogEntry</b> object.</param>
        [WebMethod]
        public void WriteLogEntry(byte[] serializedLogEntry)
        {
            try
            {
                LogEntry logEntry = (LogEntry)Serializer.DeserializeWithBinaryFormater(serializedLogEntry);
                Logger.Write(logEntry);
            }
            catch (Exception e)
            {
                WsMethodReceiver.LogError(e);
            }
        }
    }
}
